/*
(c) 2010 - Open Source Business Foundation e. V. (www.osbf.de)
This software is provided under Microsoft Reciprocal License (Ms-RL)
(http://www.microsoft.com/opensource/licenses.mspx#Ms-RL)
All other rights reserved
*/

function findElementNodes(node, elementName) {
  var result = new Array();
  if ((node.nodeType == Node.ELEMENT_NODE) && (node.nodeName == elementName)) {
    result.push(node);
  }
  var children = node.childNodes;
  for (var i = 0; i < children.length; i++) {
    var elementChildren = this.findElementNodes(children[i], elementName);
    for (var j = 0; j < elementChildren.length; j++) {
      result.push(elementChildren[j]);
    }
  }
  return result;
}

function fullUrl(doc, rel) {
  if (rel) {
  	if (rel.match(/^https?:\/\//))
    	return rel;
  
  	if (rel.charAt(0) == '/') {
    	doc.location.href.match(/(https?:\/\/[^\/]+)\/.*/);
  	} else {
    	doc.location.href.match(/(.*\/)[^\/]*/);
  	}
  	return RegExp.$1 + rel;
  }
  return rel;
}

function trim(str) {
  if (!str) return str;
  return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

